---@class Battle.StateBase
local StateBase = Battle.CreateClass("StateBase")
Battle.StateBase = StateBase
function StateBase:ctor(stateId)
    self.stateId = stateId
    ---@type Battle.Entity
    self.actor = nil
    self.isEnter = false
    self.isExit = false
    self.isFinished = false
    self.delayFinishedTime = -100
    self.nextStateId = 0
    self.isPlaying = false
    self:Init()
end
---@param actor Battle.Entity
function StateBase:BaseEnter(actor,data)
    self.actor = actor
    self.data = data
    if self.isEnter then
        self:BaseReEnter()
        return
    end
    self.delayFinishedTime = -100
    self.isFinished = false
    self.isEnter = true
    self.isExit = false
    self.isPlaying = false
    self:OnEnter()
end
function StateBase:BaseReEnter()
    self:OnReEnter()
end
function StateBase:BaseExit(forceExit)
    if self.isExit then
        return
    end
    self.isExit = true
    self:OnExit(forceExit)
    self.actor = nil
    self.data = nil
    self.isEnter = false
    self.isPlaying = false
end
function StateBase:PlayAction(name)
    if self.isPlaying then return end
    self.isPlaying = true
    self.actor.eventSystem:FireEvent(Battle.Event.ActorAnimatorPlay, Battle.EventArgs.AnimatorPlayArgs:Create( name))
end

function StateBase:SetDelayFinished(delay)
    self.delayFinishedTime = delay
    self.isFinished = delay < 0 and true or false
end
function StateBase:IsFinished()
    return self.isFinished
end
function StateBase:BaseUpdate(dt)
    if self.delayFinishedTime >= 0 then
        self.delayFinishedTime = self.delayFinishedTime - dt
        if self.delayFinishedTime < 0 then
            self.isFinished = true
            self:OnDelayFinished()
        end
    end
    self:Update(dt)
end
function StateBase:GetNextStateId()
    return self.nextStateId
end
function StateBase:SetNextStateId(id)
    self.nextStateId = id
end
--region 子类重写

function StateBase:Init()

end
function StateBase:OnEnter()

end
function StateBase:OnReEnter()
end
function StateBase:OnExit()

end
function StateBase:Update(dt)

end
function StateBase:OnDelayFinished()

end
--endregion 子类重写